<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>标题</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <!-- <input type="text" v-bind:value="nickname" @input="nickname=$event.target.value">  -->
        {{num1}}--{{num2}}
        <counter v-model="num1"></counter>
        <counter :value='num2' @input="num2=$event"></counter>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

    <script>
        Vue.component('counter', {
            props: ['value'],
            data() {
                return {
                    privite_num: this.value
                }
            },
            watch: {
                privite_num(val) {
                    this.$emit('input', val)
                }
            },
            template: `
            <div>
                {{value+10}}
            <button @click="privite_num--">-</button>
            <input type="text" v-model.number.tirm="privite_num">
            <button @click="privite_num++">+</button>
        </div>
            `
        })

        new Vue({
            el: "#app",
            data() {
                return {
                    num1: 10,
                    num2: 12
                }
            },

        })
    </script>
</body>

</html>